package koction.controller;

import java.util.ArrayList;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import koction.model.chatting.ChattingService;
import koction.model.chatting.Message;
import koction.model.consumer.ConsumerVO;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class ChatController {
	@Resource(name="chattingServiceImpl")
	private ChattingService chatting;
	
	@RequestMapping("/startChat.do")
	public String startChar(){
		return "WEB-INF/view/chatRoom/startChat";
	}
	@RequestMapping("/getMessageList.do")
	@ResponseBody
	public ArrayList<Message> getMessageList(Message message){
		return chatting.receiveMessage(message.getMessageNo());
	}
	
	@RequestMapping("/enterChat.do")
	@ResponseBody
	public ArrayList<Message> startChat(Message message){
		int no=chatting.startChat(message);
		return chatting.receiveMessage(no);
	}
	
	@RequestMapping("/sendMessage.do")
	@ResponseBody
	public boolean sendMessage(Message message){
		chatting.sendMessage(message);
		return true;
	}
	
	@RequestMapping("/endChat.do")
	@ResponseBody
	public boolean endChat(Message message){
		chatting.endChat(message);
		
		return true;
	}
	
}
